package edu.chl.da.ejb.core;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * This class is the primary key for a seat.
 * @author Jakob
 */
@Embeddable
public class SeatPK implements Serializable {
    @Basic(optional = false)
    @Column(name = "AIRPLANE")
    private int airplane;
    @Basic(optional = false)
    @Column(name = "SEATNO")
    private int seatno;
    @Basic(optional = false)
    @Column(name = "ROW")
    private int row;

    public SeatPK() {
    }

    public SeatPK(int airplane, int seatno, int row) {
        this.airplane = airplane;
        this.seatno = seatno;
        this.row = row;
    }

    public int getAirplane() {
        return airplane;
    }

    public void setAirplane(int airplane) {
        this.airplane = airplane;
    }

    public int getSeatno() {
        return seatno;
    }

    public void setSeatno(int seatno) {
        this.seatno = seatno;
    }

    public int getRow() {
        return row;
    }

    public void setRow(int row) {
        this.row = row;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) airplane;
        hash += (int) seatno;
        hash += (int) row;
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SeatPK)) {
            return false;
        }
        SeatPK other = (SeatPK) object;
        if (this.airplane != other.airplane) {
            return false;
        }
        if (this.seatno != other.seatno) {
            return false;
        }
        if (this.row != other.row) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.chl.da.ejb.core.SeatPK[airplane=" + airplane + ", seatno=" + seatno + ", row=" + row + "]";
    }

}
